package com.yssoft.service.special;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yssoft.datasource.DataSource;
import com.yssoft.entity.special.TsThreeYearsSalesEntity;
import com.yssoft.mapper.special.TsThreeYearsSalesMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Arrays;
import java.util.UUID;

/**
 * 近三年销售情况Service接口
 * @author: ZhouZhou
 * @date 2025-07-26 18:05:07
 */
@Service
public class TsThreeYearsSalesService extends ServiceImpl<TsThreeYearsSalesMapper, TsThreeYearsSalesEntity> {

	@Resource
	private TsThreeYearsSalesMapper tsThreeYearsSalesMapper;

	/**
	 * mybaitis-plus 单表页面分页查询
     */
/*	public PageUtil findPage(Map<String, Object> params) {
		QueryWrapper<TsThreeYearsSalesEntity> queryWrapper = new QueryWrapper<TsThreeYearsSalesEntity>();
		String companyId = (String) params.get("companyId");
		String deleteFlag = (String) params.get("deleteFlag");
		String year = (String) params.get("year");
		String sale = (String) params.get("sale");
		String deleteTime = (String) params.get("deleteTime");
		String createId = (String) params.get("createId");
		String updateId = (String) params.get("updateId");
		String deleteId = (String) params.get("deleteId");
		Page<TsThreeYearsSalesEntity> page = tsThreeYearsSalesMapper.selectPage(new Query<TsThreeYearsSalesEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }*/

	/**
	 * 自定义分页查询，含关联实体对像
	 */
	/*public PageUtil findPage(Map<String, Object> params,TsThreeYearsSalesEntity tsThreeYearsSalesEntity) {
		params.put("__limit", "10000");
		params.put("__page", "0");
		tsThreeYearsSalesEntity.setCompanyId(Long.parseLong(tsThreeYearsSalesEntity.getId()));

		Page<TsThreeYearsSalesEntity> page = tsThreeYearsSalesMapper.findPage(new Query<TsThreeYearsSalesEntity>(params).getPage(),
					tsThreeYearsSalesEntity,
				(String) params.get(Constant..SQL_FILTER));
		return new PageUtil(page);
	}*/

	/**
	* 查列表
	*/
	public List<TsThreeYearsSalesEntity> findList(TsThreeYearsSalesEntity tsThreeYearsSalesEntity){
		return tsThreeYearsSalesMapper.findList(tsThreeYearsSalesEntity);
	}

	/**
     * 保存
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean addTsThreeYearsSales(TsThreeYearsSalesEntity tsThreeYearsSales){
		tsThreeYearsSales.setId(UUID.randomUUID().toString().replaceAll("-", ""));
/*
		tsThreeYearsSales.setCreateBy(loginUser.getId().toString());
*/
		if(this.save(tsThreeYearsSales)){
			return true;
		}
        return false;
    }

	/**
     * 修改根居ID
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean update(TsThreeYearsSalesEntity tsThreeYearsSales) {
		if(this.updateById(tsThreeYearsSales)){
			return true;
		}
		return false;
	}

	/**
	 * 软删除
	 */
	@Transactional(rollbackFor = Exception.class)
	public boolean delete(TsThreeYearsSalesEntity entity) {
		entity.setDeleteFlag(1);
		return this.updateById(entity);
	}
}
